import { CoolController, BaseController } from '@cool-midway/core';
import { Body, Inject, Post, Get, Query } from '@midwayjs/core';
import { UserFeedbackInfoEntity } from '../../entity/info';
import { UserFeedbackInfoService } from '../../service/info';

/**
 * userfeedback模块-用户反馈信息
 */
@CoolController({
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  entity: UserFeedbackInfoEntity,
  service: UserFeedbackInfoService,
  pageQueryOp: {
    keyWordLikeFields: ['feedbackContent', 'contactInfo'],
    fieldEq: ['feedbackType', 'processStatus'],
    where: async (ctx) => {
      return [
        ['a.userId = :userId', { userId: ctx.request.body.userId }],
      ];
    },
  }
})
export class AdminUserFeedbackInfoController extends BaseController {
  @Inject()
  userFeedbackInfoService: UserFeedbackInfoService;

  @Post('/detail', { summary: '获取反馈详情' })
  async detail(@Body('feedbackId') feedbackId: number) {
    return this.ok(await this.userFeedbackInfoService.info(feedbackId));
  }
}
